package com.wn55.hrms.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wn55.hrms.entity.LaborContract;
import com.wn55.hrms.mapper.LaborContractMapper;
import com.wn55.hrms.service.vo.ContractVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ContractService {

    private LaborContractMapper laborContractMapper;

    @Autowired
    public void setLaborContractMapper(LaborContractMapper laborContractMapper){this.laborContractMapper=laborContractMapper;}

    public PageInfo<ContractVo> initContract(Integer now, Integer size, String name){
        PageHelper.startPage(now, size);
        List<ContractVo> list = laborContractMapper.listByCondition(name);
        return new PageInfo<>(list);
    }

    public void add(LaborContract laborContract) {
        laborContractMapper.insert(laborContract);
    }

    public void update(LaborContract laborContract) {
        laborContractMapper.updateByPrimaryKey(laborContract);
    }

    public void delete(int id) {
        laborContractMapper.deleteByPrimaryKey(id);
    }
}
